﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DBUtility;
using Model;

namespace DAL
{
    public class DDeviceGpsInfo
    {
        public int AddGpsInfoInArray(DeviceGpsInfo[] gpsInfos)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set names  'utf8';");
            strSql.Append("insert into tdevicegpshistory");
            strSql.Append("(Emi,PhoneNumber,Lat,Lng,Angle,Speed,State,UpdateTime)");
            strSql.Append(" values ");
            foreach (DeviceGpsInfo gpsInfo in gpsInfos)
            {
                strSql.Append("('");
                strSql.Append(gpsInfo.Emi);
                strSql.Append("','");
                strSql.Append(gpsInfo.PhoneNumber);
                strSql.Append("',");
                strSql.Append(gpsInfo.Lat);
                strSql.Append(",");
                strSql.Append(gpsInfo.Lng);
                strSql.Append(",");
                strSql.Append(gpsInfo.Angle);
                strSql.Append(",");
                strSql.Append(gpsInfo.Speed);
                strSql.Append(",");
                strSql.Append(gpsInfo.State);
                strSql.Append(",'");
                strSql.Append(gpsInfo.UpdateTime);                
                strSql.Append("'),");                
            }
            strSql.Remove(strSql.Length - 1, 1);
            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString());
            return rows;
        }

    }
}
